package com.example.contact.dao

import androidx.room.Dao
import androidx.room.Query
import com.example.contact.model.Contact
import com.example.featuresdk.model.User
import com.example.featuresdk.dao.BasicDao
import kotlinx.coroutines.flow.Flow

@Dao
interface ContactDao: BasicDao<Contact> {

    @Query("select * from contact c inner join user u on c.contactId = u.id where c.ownerId = :ownerId")
    fun getAll(ownerId: Long): Flow<Map<Contact, User>>

    @Query("select * from contact c where c.ownerId = :ownerId and c.contactId = :contactId")
    suspend fun getOne(ownerId: Long, contactId: Long): Contact?
}